<!DOCTYPE html>
<html>
<head>
{{template "common_header.html" .}}
</head>
<body>
<div class="x-body">
    <form class="layui-form" method="post" onsubmit="return false;" id="doc-add-account-form">
        <div class="layui-form-item">
            <label class="layui-form-label">姓名</label>
            <div class="layui-input-block">
                <input type="text" name="name" placeholder="姓名" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">账号</label>
            <div class="layui-input-block">
                <input type="text" name="account" placeholder="账号" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">密码</label>
            <div class="layui-input-block">
                <input type="password" name="password" placeholder="密码" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">头像</label>
            <div class="layui-input-block">
                <input type="text" name="photo" placeholder="头像图片地址" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">类型</label>
            <div class="layui-input-block">
                <input type="radio" name="is_super" value="0" title="普通账号" checked>
                <input type="radio" name="is_super" value="1" title="超级管理员">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">部门</label>
            <div class="layui-input-block">
                <input type="radio" name="department" value="1" title="大保健">
                <input type="radio" name="department" value="2" title="大健康">
                <input type="radio" name="department" value="3" title="微爱">
                <input type="radio" name="department" value="4" title="技术中心">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">业务线</label>
            <div class="layui-input-block">
                {{range $bs_index, $bs := .business_line_list}}
                    <input type="checkbox" name="business_line[]" value="{{$bs.key}}" title="{{$bs.name}}" lay-skin="primary">
                {{end}}
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">状态</label>
            <div class="layui-input-block">
                <input type="radio" name="status" value="0" title="开启" checked>
                <input type="radio" name="status" value="1" title="禁用">
            </div>
        </div>
        <div class="layui-form-item" style="margin-top:50px;">
            <button class="layui-btn layui-btn-normal" id="submit-btn" style="width:100%;">保存</button>
        </div>
    </form>
</div>
{{template "common_js.html" .}}
<script>
    layui.use('element', function(){
        var element = layui.element;
    });

    $(function(){
        $("#submit-btn").click(function () {
            var data = $("#doc-add-account-form").serialize();
            var url = "/doAddAccount";
            $.post(url, data, function (resp) {
                if(resp.en == 200) {
                    layer.msg(resp.em);
                    // 获得frame索引
                    var index = parent.layer.getFrameIndex(window.name);
                    //关闭当前frame
                    parent.layer.close(index);
                    parent.location.reload();
                } else {
                    layer.msg(resp.em);
                }
            });
        });

    });
</script>
</body>
</html>